Read a file and store lines into an arrayΒΆ

Read a file line by line store it into an array.
def file_read(fname):

    A = []
    with open(fname) as f:
        for line in f:
            A.append(line)
        print(A)

# test
file_read('test.txt')

Output:

['Welcome to w3resource.com.\n', 'Append this text.Append this text.Append this text.\n', 'Append this text.\n
', 'Append this text.\n', 'Append this text.\n', 'Append this text.\n']